package com.sbc.ai.controller;

import org.springframework.ai.openai.OpenAiChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SimpleAiController {

	private final OpenAiChatClient client;

	@Autowired
	public SimpleAiController(OpenAiChatClient client) {
		this.client = client;
	}

	@GetMapping("/talk")
	public String completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
		return client.call(message);
	}
}
